//
//  CPDockItem.m
//  财富管家
//
//  Created by rimi on 15/9/25.
//  Copyright (c) 2015年 rimicp. All rights reserved.
//

#import "CPDockItem.h"

@implementation CPDockItem

#pragma mark - 初始化方法
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 1.自动伸缩(高度 + 右边间距)
        self.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin;
    }
    return self;
}


- (void)setFrame:(CGRect)frame
{
    frame.size = CGSizeMake(100, 40);
    [super setFrame:frame];
}

// 没有高亮状态
- (void)setHighlighted:(BOOL)highlighted { }

#pragma mark - 设置按钮内部的图片
- (void)setIcon:(NSString *)icon selectedIcon:(NSString *)selectedIcon {
    self.icon = icon;
    self.selectedIcon = selectedIcon;
}

- (void)setIcon:(NSString *)icon
{
    _icon = icon;
    [self setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
}

- (void)setSelectedIcon:(NSString *)selectedIcon
{
    _selectedIcon = selectedIcon;
    [self setImage:[UIImage imageNamed:selectedIcon] forState:UIControlStateDisabled];
}


#pragma mark 调整内部ImageView的frame
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat imageX = 0;
    CGFloat imageY = 0;
    CGFloat imageWidth = 100;
    CGFloat imageHeight = 40;
    return CGRectMake(imageX, imageY, imageWidth, imageHeight);
}

#pragma mark 调整内部UILabel的frame
//- (CGRect)titleRectForContentRect:(CGRect)contentRect
//{
//    CGFloat titleX = 50 + 10;
//    CGFloat titleHeight = kDockItemH;
//    CGFloat titleY = 0;
//    CGFloat titleWidth = kDockItemW - 50 - 10;
//    return CGRectMake(titleX, titleY, titleWidth, titleHeight);
//}


@end
